package com.sunny.oauth2;

import org.springframework.context.annotation.Bean;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;

@EnableAuthorizationServer
@org.springframework.context.annotation.Configuration
public class Configuration {

    @Bean
    public AuthorizationServerConfigurerAdapter getAuthorizationServerConfigurerAdapter(){
        return new AuthorizationServerConfigurerAdapter(){
            @Override
            public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
                clients.inMemory() // 使用in-memory存储
                        .withClient("client") // client_id
                        .secret("secret") // client_secret
                        .authorizedGrantTypes("authorization_code") // 该client允许的授权类型
                        .scopes("app"); // 允许的授权范围
            }
        };
    }

}
